﻿@using MyCompanyName.AbpZeroTemplate.Web.Areas.AppAreaName.Models.AuditLogs
@model EntityChangeDetailModalViewModel

<div class="modal-header">
    <h4 class="modal-title">
        <span>@L("Detail") - @L(Model.EntityTypeFullName)</span> <br/>
        <small>@Html.Raw(L("CreatedAtByUser", Model.ChangeTime, Model.UserName))</small>
    </h4>
    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
        <i aria-hidden="true" class="ki ki-close"></i>
    </button>
</div>
<div class="modal-body">
    <table id="EntityPropertyChangesTable" class="table table-separate table-head-custom no-footer dtr-inline dt-responsive nowrap">
        <thead>
        <tr>
            <th>@L("Property")</th>
            <th>@L("OriginalValue")</th>
            <th>@L("NewValue")</th>
        </tr>
        @foreach (var propertyChange in Model.EntityPropertyChanges)
        {
            <tr>
                <td>
                    <strong>@propertyChange.PropertyName</strong>
                </td>
                @if (Type.GetType(propertyChange.PropertyTypeFullName) == typeof(DateTime))
                {
                    <td>@(string.IsNullOrEmpty(propertyChange.OriginalValue) ? "" : DateTimeOffset.Parse(propertyChange.OriginalValue.Replace("\"", "")).ToString("g"))</td>
                    <td>@(string.IsNullOrEmpty(propertyChange.NewValue) ? "" : DateTimeOffset.Parse(propertyChange.NewValue.Replace("\"", "")).ToString("g"))</td>
                    continue;
                }

                <td>@(propertyChange.OriginalValue == "null" ? "" : propertyChange.OriginalValue)</td>
                <td>@(propertyChange.NewValue == "null" ? "" : propertyChange.NewValue)</td>
            </tr>
        }
        </thead>
    </table>
</div>
<div class="modal-footer">
    <button type="button" class="btn btn-light-primary font-weight-bold close-button" data-dismiss="modal">@L("Close")</button>
</div>
